﻿using System;
using Core.Authenticated;
using Core.Library;
using DataObject;
using DataObject.Ref;

namespace CMS.Controls.AntiClone
{
    public partial class EmailClone : AuthenticatedControl
    {
        protected string ReturnUrl;
        protected void Page_Load(object sender, EventArgs e)
        {
            ReturnUrl = Utils.GetIdFromRequestString(Utils.ReturnUrl, string.Empty);

            if (!IsPostBack)
            {
                BindObject();
            }
        }

        private void BindObject()
        {
            var o = RefController.Ref_GetStringEmailClone();
            if (o == null) return;

            txtName.Text = o;
        }

        public void ManagerAction()
        {
            RefController.Ref_UpdateTextValueByKey(Constants.RefKey.EmailClone, txtName.Text);
            Response.Redirect(ReturnUrl);
        }

        #region Buttons

        protected void BtnSave(object sender, EventArgs e)
        {
            ManagerAction();
        }
        #endregion
    }
}